//Purpose: socket operation wrapper and net buffer
//
//Created: Daly 2012-04-01

#include "ax_common.h"

#ifndef _AX_NET_H_
#define _AX_NET_H_


//seld expand net buffer
class AxNetBuffer
{
public:
	AxNetBuffer();
	~AxNetBuffer();
	AxNetBuffer(unsigned int n);
	void alloc(unsigned int n);
	//pop n bytes ahead. 
	//you should call push first to copy into your buffer
	int pop(unsigned int n);
	//copy to buffer
	int push(const char* src, unsigned int size);
	void shift();
	unsigned int size() { return _len; }
	char* datap() { return buf + _start; }  //get data pointer
	void reset(unsigned int size);

private:
	char* buf;
	unsigned int _len;   //valid data length
	unsigned int _alloc_size;
	unsigned int _start;
	unsigned int _end;
};

#endif 
